﻿<%@ page import="com.cai.dao.GoodsDao" %>
<%@ page import="com.cai.dao.impl.GoodsDaoImpl" %>
<%@ page import="java.util.List" %>
<%@ page import="com.cai.entity.ItemType" %>
<%@ page import="com.cai.dao.UtilsDao" %>
<%@ page import="com.cai.dao.impl.UtilsDaoImpl" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    GoodsDao goodsDao = new GoodsDaoImpl();
    List<ItemType> list = goodsDao.selectItemType();
    request.setAttribute("item_type", list);
%>
<head>
    <title>器材分类</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <script src="js/jquery.js"></script>
    <link href="style/adminStyle.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="wrap">
    <div class="page-title">
        <span class="modular fl"><i></i><em>器材分类</em></span>
        <span class="modular fr"><a href="add_category.jsp" class="pt-link-btn">+添加新分类</a></span>
    </div>

    <table class="list-style">
        <tr>
            <th>序号</th>
            <th>编号</th>
            <th>分类名称</th>
            <th>操作</th>
        </tr>
        <%--c：foreach--%>
        <c:forEach items="${requestScope.item_type}" var="itemType" varStatus="status">
            <tr>
                <td class="center">
                    <input type="checkbox"/>
                    <span>${status.count}</span>
                </td>
                <td class="center">${itemType.itemType_id}</td>
                <td class="itemTypeName center">${itemType.itemType_name}</td>
                <td class="center"><a class="block " title="移除"><img class="btn_delete"
                                                                     src="images/icon_trash.gif"/></a></td>
            </tr>
        </c:forEach>

    </table>

    <!-- BatchOperation -->
    <div style="overflow:hidden;">
        <!-- Operation -->
        <div class="BatchOperation fl">
            <input type="checkbox" id="del"/>
            <label for="del" class="btnStyle middle">全选</label>
            <input type="button" value="批量删除" class="btnStyle"/>
        </div>
        <!-- turn page -->
        <div class="turnPage center fr">
            <a>第一页</a>
            <a>1</a>
            <a>最后一页</a>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        //删除物品类型
        $("[class=btn_delete]").click(function () {
            $(this).parent().parent().parent().hide()
            var itemTypeName = $(this).parent().parent().parent().find(".itemTypeName").text()
            $.ajax({
                url: "/cai/itemTypeDelete",
                type: "post",
                data: {
                    "itemTypeName": itemTypeName
                },
                success: function (data) {
                    if (parseInt(data) !== 0) {
                        alert("删除成功")

                    } else {
                        alert("删除失败")
                    }
                }
            })
        })
    })
</script>
</body>
</html>